package projectsys.core.utils.encrypt;

import java.math.BigInteger;

/**
 * 加密工具(Encrypt.java)
 * @author my
 *
 */
public class EncryptUtil {
	/**
	 * MD5加密
	 * 
	 * @param inputString
	 * @return
	 * @throws Exception
	 */
	public static String md5(String inputString) throws Exception {
		byte[] inputData = inputString.getBytes();
		BigInteger md5 = new BigInteger(Coder.encryptMD5(inputData));
		return md5.toString(16);
	}
	
	/**
	 * SHA加密
	 * 
	 * @param inputString
	 * @return
	 * @throws Exception
	 */
	public static String sha(String inputString) throws Exception {
		byte[] inputData = inputString.getBytes();
		BigInteger sha = new BigInteger(Coder.encryptSHA(inputData));
		return sha.toString(32);
	}
	
	/**
	 * HMAC加密
	 * 
	 * @param inputString
	 * @return
	 * @throws Exception
	 */
	public static String mac(String inputString) throws Exception {
		byte[] inputData = inputString.getBytes();
		BigInteger mac = new BigInteger(Coder.encryptHMAC(inputData,
				inputString));
		return mac.toString(16);
	}
}
